<link href="/wang-editor/style.css" rel="stylesheet">
<style>
    #editor—wrapper {
        border: 1px solid #ccc;
        z-index: 100; /* 按需定义 */
    }
    #toolbar-container { border-bottom: 1px solid #ccc; }
    #editor-container { height: 500px; }
</style>
<input type="hidden" name="id" value="{{ $product->id ?? '' }}" />
<div class="layui-form-item">
    <label for="" class="layui-form-label">分类</label>
    <div class="layui-input-inline">
        <select name="top_category_id" lay-filter="parent_id" lay-search>
            <option value="">请选择分类</option>
            @foreach($cates as $cate)
                <option value="{{ $cate->id }}" @if(isset($parent_id)&&$parent_id==$cate->id)selected @endif >{{ $cate->name }}</option>
            @endforeach
        </select>
    </div>
    <div class="layui-input-inline">
        <select name="category_id" lay-filter="category_id" id="category_id" lay-search lay-verify="required">
            @isset($product->id)
                @foreach($sibling_categories as $sib)
                    <option value="{{ $sib->id }}" @if(isset($product->category_id)&&$product->category_id==$sib->id)selected @endif >{{ $sib->name }}</option>
                @endforeach
            @endisset
        </select>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">名称</label>
    <div class="layui-input-block">
        <input type="text" name="title" value="{{$product->title ?? ''}}" lay-verify="required" placeholder="名称" class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">关键词</label>
    <div class="layui-input-block">
        <input type="text" name="keyword" value="{{$product->keyword ?? ''}}"  placeholder="简单介绍" class="layui-input" >
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">描述</label>
    <div class="layui-input-block">
        <textarea name="description" required lay-verify="required" placeholder="" class="layui-textarea">{{ $product->description ?? '' }}</textarea>
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">规格设置</label>
    <div class="layui-input-block">
        <div id="toolbar">
            <div>
                <button type="button" class="layui-btn layui-btn-sm" data-type="addRow" title="添加一行">
                    <i class="layui-icon layui-icon-add-1"></i> 添加一行
                </button>
            </div>
        </div>
        <div id="tableRes" class="table-overlay">
            <table id="dataTable" lay-filter="dataTable" class="layui-hide"></table>
        </div>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">单位</label>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" name="unit" placeholder="" value="{{ $product->unit ?? "" }}">
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">成交数</label>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" name="score" placeholder="" value="{{ $product->score ?? 0 }}">
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">类型</label>
    <div class="layui-input-block">
        <input type="radio" name="type" value="1" title="特价" @if(@isset($product->type) && $product->type==1) checked @endif>
        <input type="radio" name="type" value="2" title="热销" @if(@isset($product->type) && $product->type==2) checked @endif>
        <input type="radio" name="type" value="3" title="普通" @if(@!isset($product->type) || (@isset($product->type) && $product->type==3)) checked @endif>
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">首页置顶轮播</label>
    <div class="layui-input-inline">
        <input type="number" class="layui-input" name="is_banner" placeholder="数字越大越靠前" value="{{ $product->is_banner ?? 0 }}">
    </div>
    <div class="layui-form-mid layui-word-aux">0为不置顶</div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">缩略图</label>
    <div class="layui-input-block">
        <div class="layui-upload">
            <button type="button" class="layui-btn layui-btn-sm uploadPic"><i class="layui-icon">&#xe67c;</i>缩略图上传</button>
            <div class="layui-upload-list" >
                <ul class="layui-upload-box layui-clear">
                    @if(isset($product->cover))
                        <li><img src="{{ $product->cover }}" /><p>上传成功</p></li>
                    @endif
                </ul>
                <input type="hidden" name="cover" class="layui-upload-input" lay-verify="required" value="{{ $product->cover ?? '' }}">
            </div>
        </div>
    </div>
</div>
<div class="layui-form-item">
    <label for="" class="layui-form-label">轮播图</label>
    <div class="layui-input-block">
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="imagesUpload">轮播图上传</button>
            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;overflow: auto">
                预览图：
                <div class="layui-upload-list" id="imagesList">
                    @if(@isset($product) && $product->images)
                        @foreach($product->images as $image)
                            <li>
                                <a href="javascript:;" class="delete-images" title="删除">x</a>
                                <img src="{{$image}}" />
                                <p>上传成功</p>
                                <input type="hidden" name="images[]" value="{{$image}}" />
                            </li>
                        @endforeach
                    @endif
                </div>
            </blockquote>
        </div>
    </div>
</div>
<textarea name="" id="neirong" cols="30" rows="10" style="display: none">{!! $product->detail ?? old('detail') !!}</textarea>
<div class="layui-form-item">
    <label for="" class="layui-form-label">详情</label>
    <div class="layui-input-block" id="editor—wrapper">
        {{--        <script id="detail" name="detail" type="text/plain" style="width: 100%;height: 1500px;">--}}
        {{--            {!! $product->detail ?? old('detail') !!}--}}
        {{--        </script>--}}
        <div id="toolbar-container"></div>
        <div id="editor-container" name="detail"></div>
    </div>
</div>

<div class="layui-form-item">
    <label for="" class="layui-form-label">排序</label>
    <div class="layui-input-inline">
        <input type="number" class="layui-input" name="sort" placeholder="数字越大越靠前" value="{{ $product->sort ?? 0 }}">
    </div>
</div>

<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="button" class="layui-btn" lay-submit="" lay-filter="productC">确 认</button>
        <a class="layui-btn" href="{{ $_GET['backUrl'] ?? route('product.index')}}" >返 回</a>
    </div>
</div>

<style>
    #imagesList {
        flex: 1;
    }
    #imagesList li {
        float: left;
        margin-right: 5px;
    }
    #imagesList li img {
        width: 200px;
    }
    /*******详情长图样式单独设置*********/
    #detailList {
        flex: 1;
    }
    #detailList li {
        float: left;
        margin-right: 5px;
    }
    #detailList li img {
        width: 200px;
    }
    /*添加sku表格时input标签不受td高度限制*/
    .layui-table-cell {
        height: auto;
    }
    /*layer弹层标题居中*/
    .layui-layer-title{
        text-align: center;
    }
    /*轮播图删除按钮*/
    .delete-images {
        display: block;text-align: right;padding-right: 10px;background-color: #f8eaea;
    }
</style>